home *** CD-ROM | disk | FTP | other *** search
- -- card: 29601 from stack: in
- -- bmap block id: 0
- -- flags: 0000
- -- background id: 4755
- -- name:
-
-
- -- part 1 (button)
- -- low flags: 00
- -- high flags: 0001
- -- rect: left=13 top=29 right=57 bottom=351
- -- title width / last selected line: 0
- -- icon id / first selected line: 0 / 0
- -- text alignment: 1
- -- font id: 0
- -- text size: 12
- -- style flags: 0
- -- line height: 16
- -- part name: New Button
-
-
- -- part 2 (field)
- -- low flags: 00
- -- high flags: 0007
- -- rect: left=30 top=76 right=296 bottom=478
- -- title width / last selected line: 0
- -- icon id / first selected line: 0 / 0
- -- text alignment: 0
- -- font id: 4
- -- text size: 9
- -- style flags: 0
- -- line height: 12
- -- part name: code
-
-
- -- part contents for background part 6
- ----- text -----
- Example of user-defined data types
-
- -- part contents for card part 2
- ----- text -----
- /*
- * FILE: personnel.c
- * AUTHOR: R.G.
- * CREATED: June 20, 1990
- *
- * C program illustrating scope and use of user-defined data types.
- *
- * PROJECT CONTENTS:
- * personnel.c, ANSI, oops libraries
- */
-
- # include <stdio.h> /* declares standard I/O functions */
- # include <string.h> /* declares string handling functions */
-
- /******************************************************************
- * Definition of enum day_of_week type (file scope)
- ******************************************************************/
- enum day_of_week
- {
- Monday, Tuesday, Wednesday, Thursday, Friday, Saturday, Sunday
- };
- /* synonym for 'enum day_of_week' is simply 'day_of_week': */
- typedef enum day_of_week day_of_week;
-
- /******************************************************************
- * Definition of struct personnel_rec type (file scope)
- ******************************************************************/
- struct personnel_rec
- {
- /* declare types of members, without allocating space yet: */
- char name[80];
- day_of_week days_off[2]; /* member has enum type */
- /* legal circular reference using pointer: */
- struct personnel_rec *boss;
- };
- typedef struct personnel_rec personnel_rec;
-
- /******************************************************************
- * main() function
- ******************************************************************/
- main()
- {
- /* allocate two struct variables with block scope: */
- personnel_rec employee[2];
-
- /* string copy function from standard libraries: */
- strcpy(employee[0].name,"Andrew Lipton");
- employee[0].days_off[0] = Saturday;
- employee[0].days_off[1] = Sunday;
- employee[0].boss = &employee[0]; /* Andy's his own boss! */
-
- strcpy(employee[1].name,"James Nutmeg");
- employee[1].days_off[0] = Sunday;
- employee[1].days_off[1] = Wednesday;
- employee[1].boss = &employee[0];
-
- /* use standard library function printf() for output: */
- printf("First employee: %s and his boss: %s\n",
- employee[0].name,(employee[0].boss)->name);
- printf("Second employee: %s and his boss: %s\n",
- employee[1].name,(employee[1].boss)->name);
- }
-
-
-
-
- -- part contents for background part 4
- ----- text -----
- This is a complete example demonstrating C data types:
-
- -- part contents for background part 7
- ----- text -----
- 82